<%@ page session="true" %>
<%
 
	String userid = (String) session.getAttribute("userid");
	String db = (String) session.getAttribute("db");
	
    if (userid == null)
    {
       response.sendRedirect("login.jsp");
    }
	if (db == null)
    {
		//session.removeAttribute("userid");
        //session.removeAttribute("name");
        //session.invalidate();
        response.sendRedirect("login.jsp?db=null");  
    }

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<link href="css/medbill.css" rel="stylesheet" type="text/css" />
<title>PMS Home</title>
<script language="javascript">
var searchParam="";
function showHideSearchByName()
{
	
	if(document.searchEmp.R1[0].checked==true){
			
		document.getElementById("searchByNameDiv").style.display="block";
	  	document.searchEmp.address.style.display="none";
	  	searchParam = "fname="+document.searchEmp.first_name.value;
	  	searchParam += "&lname="+document.searchEmp.last_name.value;	  	
	  		  	
	}else if(document.searchEmp.R1[1].checked==true){	
		
		document.getElementById("searchByNameDiv").style.display="none";
	  	document.searchEmp.address.style.display="block";	
	  	searchParam = "address="+document.searchEmp.address.value;
	  	
	  	
	}else if(document.searchEmp.R1[2].checked==true){

		document.getElementById("searchByNameDiv").style.display="none";
	  	document.searchEmp.address.style.display="block";	
		searchParam = "ssn="+document.searchEmp.address.value;
	  	
	}else if(document.searchEmp.R1[3].checked==true){
		
		document.getElementById("searchByNameDiv").style.display="none";
	  	document.searchEmp.address.style.display="block";
	  	searchParam  = "patient_id="+document.searchEmp.address.value;	  	
	}
}
  function getPatientInfo()
            {    
                //document.getElementById("patient_id").value = patient_id;
                //document.getElementById("patient_name").value = patient_id;
        		//alert(searchParam);
                var xmlHttp;
                var ret="";
                try
                {  
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");    	
                }
                catch (e)
                {   
                    xmlHttp=new XMLHttpRequest();            
                }
    
                xmlHttp.onreadystatechange=function()
                {
                    if(xmlHttp.readyState==4)
                    {
                        ret=xmlHttp.responseText;
                        document.getElementById("patient_info").innerHTML=ret;      	
                    }
                }     
               	
                xmlHttp.open("GET","getPatient.jsp?"+searchParam,true);    
                xmlHttp.send(null);	
            }

function validateForm()
{	
	if(!document.searchEmp.pid){
		return false;
	}
	var selected="false";
	if(document.searchEmp.pid[0]){
		for(i=0 ; i<document.searchEmp.pid.length; i++)
		{	
			if(document.searchEmp.pid[i].checked){
				selected="true";
			}		
		}	
	}else{
		if(document.searchEmp.pid.checked){
			selected="true";
		}
	}
	if(selected=="true"){
		return true;
	}else{
		alert("Please select at least one patient");
		return false;
	}
}
</script>
</head>

<body onload="showHideSearchByName();getPatientInfo();">
<table width="860" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="204" valign="top"><%@include file="header.jsp"%></td>
  </tr>
  <tr>
    <td height="30" bgcolor="#1f226f" class="headingBlue">Medical Billing and Claim Processing Professionals</td>
  </tr>
  <tr>
    <td valign="top" bgcolor="#ccae74"><table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="470" valign="top" class="txtPageTitle">Search Patient </td>
            <td>&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="560"></td>
              </tr>
              <tr>
                <td class="txtHomeBody"></td>
              </tr>
            </table>
              <br>
<form action="patient_diag.jsp" method="post" name="searchEmp" onsubmit="return validateForm();">

<font color="red"><%if(request.getParameter("saved")!=null){out.print("Data saved succussfully.");}%></font>
<table border="0" width="100%" cellspacing="1">
	<tr>
		<th align="left" valign="top" colspan="2">Search Patient</th>
	</tr>
	<tr>
		<td width="8%" align="left" valign="top">
		</td>
		<td valign="top" width="92%"><input type="radio" value="byName" name="R1" checked onclick="showHideSearchByName()">By 
		First/Last Name<br>
		<input type="radio" value="byAddress" name="R1" onclick="showHideSearchByName()">By Address<br>
		<input type="radio" value="bySS" name="R1" onclick="showHideSearchByName()">By S.S.#<br>
		<input type="radio" value="byPatientID" name="R1" onclick="showHideSearchByName()">By Patient ID	
&nbsp;</td>
	</tr>
	<tr>
		<td width="8%">&nbsp;</td>
		<td width="92%"><div id="searchByNameDiv"><input type="text" name="first_name" size="20" onblur="showHideSearchByName();"> <input type="text" name="last_name" size="20" onblur="showHideSearchByName();"><br></div>
		<input type="text" name="address" size="42" onblur="showHideSearchByName();"/>
		<br>
		<input type="button" value="Search" onclick="getPatientInfo();"/> </td>
	</tr>
</table>
<br>
<table cellpadding="0" cellspacing="0" width="100%">
<tr><th>Search Results</th></tr>
</table>
<br>

<div id="patient_info" style="width:788px; height:280px; overflow:auto;"></div><br/>
<input type="submit" value=" Select " /><input type="button" value="Cancel" /></form>
  <br></td>
            <td width="45" valign="top">&nbsp;</td>
            <td valign="top">&nbsp;</td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="62" valign="top"><!-- #BeginLibraryItem "/Library/footer.lbi" --><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="4" bgcolor="#c7540f"></td>
      </tr>
      <tr>
        <td height="58" bgcolor="#1e2667">&nbsp;</td>
      </tr>
    </table><!-- #EndLibraryItem --></td>
  </tr>
</table>
</body>

</html>